package com.lzp.appexp.applicaton

import android.app.Application
import com.imageloader.ImageLoader
import com.imageloader.ImageLoaderConfig
import com.imageloader.ImageLoaderUtils
import com.net.NetClientConfig
import com.net.NetUtils
import com.utils.BuildConfig
import com.utils.Utils

/**
 * @describe
 * @author: lixiaopeng
 * @Date: 2019-06-12
 */
class App : Application() {
    companion object {
        var application: Application? = null
    }

    override fun onCreate() {
        super.onCreate()
        application = this
        /*if (LeakCanary.isInAnalyzerProcess(this)) {
            // This process is dedicated to LeakCanary for heap analysis.
            //You should not init your app in this process.
            return;
        }*/
        // LeakCanary.install(this);
        NetUtils.init(NetClientConfig.Builder()
                .setConnectTimeout(5000L)
                .setReadTimeOut(5000L)
                .setWriteTimeout(5000L)
                .debug(BuildConfig.DEBUG)
                .setCookieJar(null)
                .addInterceptor(null)
                .addNetInterceptor(null)
                .build())

        ImageLoader.get(this).init(ImageLoaderConfig.ImageLoaderConfigBuilder()
                .setCacheRule(null)
                .setDiskCachePath(ImageLoaderUtils.getDefaultDiskCachePath(this))
                .setMaxDiskCacheSize(100 * 1024 * 1024.toLong())
                .setMaxMemoryCacheSize(50 * 1024 * 1024.toLong())
                .setRequestClient(NetUtils.getHttpClient())
                .build())
    }
}